{php include wl_template('common/header');}
<ul class="nav nav-tabs">
	<li class="active"><a href="#">评价列表</a></li>
</ul>
<div class="app-content">
    <div class="app-filter">
        <div class="filter-action">
            <a href="{php echo web_url('store/storeComment/add')}" class="btn btn-primary">添加评论</a>
        </div>
        <div class="filter-list">
            <form action="" method="get" class="form-horizontal" role="form"  id="form2">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{MODULE_NAME}" />
                <input type="hidden" name="p" value="store" />
                <input type="hidden" name="ac" value="storeComment" />
                <input type="hidden" name="do" value="index" />
                <input type="hidden" name="type" value="{$type}" />
                <input type="hidden" name="checkone" value="{$checkone}" />
                <div class="form-group">
                    <label class="col-sm-2 control-label">评论时间</label>
                    <div class="col-sm-9">
                        {php echo tpl_select_time_info('time', array('starttime'=>date('Y-m-d H:i:s', $starttime),'endtime'=>date('Y-m-d H:i:s', $endtime)));}
                    </div>
                </div>
                <div class="form-group">
					<label class="col-sm-2 control-label">评价类型</label>
					<div class="col-sm-9">
						<div class="btn-group">
							<a href="{php echo wl_filter_url('type:');}" class="btn {if empty($_GPC['type'])}btn-primary{else}btn-default{/if}">不限</a>
							<a href="{php echo wl_filter_url('type:1');}" class="btn {if $_GPC['type'] == '1'}btn-primary{else}btn-default{/if}">真实评价</a>
							<a href="{php echo wl_filter_url('type:2');}" class="btn {if $_GPC['type'] == '2'}btn-primary{else}btn-default{/if}">模拟评价</a>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">评价状态</label>
					<div class="col-sm-9">
						<div class="btn-group">
							<a href="{php echo wl_filter_url('checkone:');}" class="btn {if empty($_GPC['checkone'])}btn-primary{else}btn-default{/if}">不限</a>
							<a href="{php echo wl_filter_url('checkone:1');}" class="btn {if $_GPC['checkone'] == '1'}btn-primary{else}btn-default{/if}">审核中</a>
							<a href="{php echo wl_filter_url('checkone:2');}" class="btn {if $_GPC['checkone'] == '2'}btn-primary{else}btn-default{/if}">已通过</a>
							<a href="{php echo wl_filter_url('checkone:3');}" class="btn {if $_GPC['checkone'] == '3'}btn-primary{else}btn-default{/if}">未通过</a>
						</div>
					</div>
				</div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">商家搜索</label>
                    <div class="col-sm-9">
                        <input type="text" name="keyword" class="form-control" value="{$_GPC['keyword']}"  placeholder="请输入商家ID"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-9">
                        <span class="btn btn-primary" id="search">搜索</span>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="app-table-list">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th class="text-center" width="5%"><input type="checkbox" name="checkall" value="" id="checkall" class="checkboxall" onclick="var ck = this.checked; $(':checkbox').each(function(){this.checked = ck});"/></th>
                        <th class="text-left" width="15%">商家</th>
                        <th class="text-left" width="15%">评价者</th>
                        <th class="text-left" width="15%">评分等级<br>评价时间</th>
                        <th class="text-center" width="10%">回复状态</th>
                        <th class="text-center" width="10%">审核状态</th>
                        <th class="text-center" width="30%">操作</th>
                    </tr>
                </thead>
                <tbody>
                    {loop $lists $li}
                        <tr id="{$li['uid']}" class="text-center">
                            <td>
                                <center><input type="checkbox" name="items[]" value="{$li['id']}" class="checkbox" /></center>
                            </td>
                            <td class="text-left">
                                <label class="label label-primary">ID:{$li['sid']}，{$li['sName']}</label>
                            </td>
                            <td class="text-left">
                                <img style="position:relative;top: -10px;"  class="scrollLoading" src="{IMAGE_PIXEL}" data-url="{$li['headimg']}" onerror="this.src='{IMAGE_NOPIC_SMALL}'" height="40" width="40"/>
                                <span style="display: inline-block">  {$li['nickname']} <br/> MID:{$li['mid']} </span>
                            </td>
                            <td class="text-left" style="color: #ff6600;">
                                {loop $li['star'] $l}<i class="fa fa-star"></i>{/loop} <br>
                                {php echo date('Y-m-d',$li['createtime']);}
                            </td>
                            <td>
                                {if $li['replyone']==1}
                                <label class="label label-default">未回复</label><br>
                                {elseif $li['replyone']==2}
                                <label class="label label-success">已回复</label><br>
                                {/if}
                            </td>
                            <td>
                                {if     $li['checkone']==1}<label class="label label-warning">评价审核中</label><br>
                                {elseif $li['checkone']==2}<label class="label label-success">评价通过</label><br>
                                {elseif $li['checkone']==3}<label class="label label-default">评价不通过</label><br>
                                {/if}
                            </td>
                            <td style="overflow:visible;">
                                {if !empty($li['orderurl'])}
                                <a class="btn btn-success btn-sm" target="_blank" href="{$li['orderurl']}">订单</a>
                                {/if}
                                <a class="btn btn-info btn-sm" href="{php echo web_url('store/storeComment/check',array('id'=>$li['id'],'pindex'=>$pindex))}">审核</a>
                                <a class="btn btn-warning btn-sm" href="{php echo web_url('store/storeComment/reply',array('id'=>$li['id'],'pindex'=>$pindex))}">回复</a>
                                <a class="btn btn-sm btn-primary" href="{php echo web_url('store/storeComment/add',array('id'=>$li['id'],'pindex'=>$pindex))}">添加</a>
                                <a class="btn btn-sm btn-danger" data-toggle="ajaxRemove" href="{php echo web_url('store/storeComment/delete',array('id'=>$li['id'],'pindex'=>$pindex))}" data-confirm="确定删除当前评论?">删除</a>
                            </td>
                        </tr>
                    {/loop}
                </tbody>
            </table>
        </div>
        <div class="app-table-foot clearfix">
            <div class="pull-left">
                <button class="btn btn-default btn-sm" type="button" onclick="location.reload();"><i class="fa fa-refresh"></i></button>
                <div class="btn-group btn-group-sm">
                    <button  class="btn btn-default" disabled="disabled" id="checkYse" onclick="checkOrDelete(2,1);">审核通过</button>
                    <button  class="btn btn-default" disabled="disabled" id="checkNo" onclick="checkOrDelete(3,1);">审核不通过</button>
                </div>
                <button class="btn btn-default btn-sm" type="button" disabled="disabled" id="delete" onclick="checkOrDelete(1,2);"><i class="fa fa-trash"></i> 删除</button>
            </div>
            <div class="pull-right">
                {$pager}
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $("#search").click(function(){
        $('#form2')[0].submit();
    })
</script>
<script>
	$(function(){
		$('.checkbox,.checkboxall').click(function(){
			var $checks=$('.checkbox:checkbox:checked');
			$('#check').attr('disabled','');
			if($checks.length>0) {
				$('#checkYse').attr('disabled',false);
				$('#checkNo').attr('disabled',false);
				$('#delete').attr('disabled',false);
			}else{
				$('#checkYse').attr('disabled',true);
				$('#checkNo').attr('disabled',true);
				$('#delete').attr('disabled',true);
			}
		});

	})
	//通过申请
	function checkOrDelete(check,type){
		var content = '';
		if(check==1 && type==2) content = '确认删除？';
		if(check==2 && type==1) content = '确认审核通过？';
		if(check==3 && type==1) content = '确认审核不通过？';
		layer.open({
		  	title: [
		    	'',
		    	'background-color:#23c6c8; color:#fff;'
		  	]
		  	,anim: 'up'
		  	,content: content
		  	,btn: ['确认', '取消']
		  	,yes:function(index){
		  		var ids = [];
				var $checks=$('.checkbox:checkbox:checked');
				$checks.each(function() {
					if (this.checked) {
						ids.push(this.value);
					};
				});
				if(type==1){
					location.href = "{php echo web_url('store/storeComment/check')}&ids="+ids+"&check="+check;
				}else if(type==2){
					location.href = "{php echo web_url('store/storeComment/delete')}&id="+ids;
				}
		  	}
		});
	}
	$('#de1').delegate('.js-delete','click',function(e){
			e.stopPropagation();
			var order_ids = [];
			var $checks=$('.checkbox:checkbox:checked');
			$checks.each(function() {
				if (this.checked) {
					order_ids.push(this.value);
				};
			});
				var $this = $(this);
				var ids = order_ids;
				util.nailConfirm(this, function(state) {
				if(!state) return;
					$.post("{php echo web_url('order/order/delete')}", { ids : ids }, function(data){
						if(!data.errno){
						util.tips("删除成功！");
						location.reload();
						};
					}, 'json');
				}, {html: '确认删除?'});
			});
</script>
{php include wl_template('common/footer');}